package shiyan;

/**
 * Created by Lenovo on 2017-05-01.
 */
abstract class Data {
    abstract public void DisplayValue();
}
class Integer extends  Data {
    int value;
    Integer() {
        value=100;
    }
    public void DisplayValue(){
        System.out.println (value);
    }


}
class Short extends  Data {
    short value1;
    short value2;
    Short() {
        value1=(short)2014;
        value2 =(short)5207;
    }
    public void DisplayValue(){
        System.out.printf ("%d%d",value1,value2);
    }
}
// Pattern Classes
abstract class Factory {
    abstract public Data CreateDataObject();
}
class IntFactory extends Factory {
    public Data CreateDataObject(){
        return new Integer();
    }
}
class ShortFactory extends Factory {
    public Data CreateDataObject(){
        return new Short();
    }
}
//Client classes
class Document {
    Data pd;
    Document(Factory pf){
        pd = pf.CreateDataObject();
    }
    public void DisplayData(){
        pd.DisplayValue();
    }
}
//Test class
public class MOCshout {
    static Document d;
    MOCshout(Document d) {
        this.d = d;
    }
    public static void main(String[] args) {
        d = new Document(new ShortFactory());
        d.DisplayData();
    }
}